package com.itgungnir.designpattern.state;

public class CandyPoppingState implements State {
	private CandyMachine candyMachine;

	public CandyPoppingState(CandyMachine candyMachine) {
		this.candyMachine = candyMachine;
	}

	@Override
	public void onMoneyInserted() {
		System.out.println("正在发放糖果，请勿操作！");
	}

	@Override
	public void onMoneyReturned() {
		System.out.println("正在发放糖果，请勿操作！");
	}

	@Override
	public void onCrankTurned() {
		System.out.println("正在发放糖果，请勿操作！");
	}

	@Override
	public void onCandyPoped() {
		candyMachine.setCandyCount(candyMachine.getCandyCount() - 1);
		System.out.println("成功发放了一颗糖果！");
		candyMachine.setState(candyMachine.getNoMoneyState());
	}
}